#include "StdAfx.h"

using namespace MySql::Data::MySqlClient;

bool sLogIn::check_pswd_employee(System::String ^ _name, System::String ^ _surname, System::String ^ _pswd){
	System::String ^ strCon = "datasource=localhost;username=root;password=;database=mpk_db";

	MySqlConnection ^ conDatabase = gcnew MySqlConnection(strCon);
	MySqlCommand    ^ cmdDatabase = gcnew MySqlCommand("SELECT * FROM pracownik;", conDatabase);

	conDatabase->Open();

	MySqlDataReader ^ myReader;
	myReader = cmdDatabase->ExecuteReader();

	bool flag = false;
	while (myReader->Read()) {
		if(myReader->GetString(1) == _name && myReader->GetString(2) == _surname && myReader->GetString(3) == _pswd){
			id = myReader->GetInt32(0);
			name = _name;
			surname = _surname;
			password = _pswd;
			flag = true;
			break;
		}
	}

   
	myReader->Close();

	conDatabase->Close();

	return flag;
}